package com.fenxiangle.yueding.feature.focus.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.fenxiangle.yueding.R;
import com.fenxiangle.yueding.entity.bo.AliPayBo;
import com.fenxiangle.yueding.entity.bo.ExtensionBo;
import com.fenxiangle.yueding.feature.extension.contract.ExtensionContract;
import com.fenxiangle.yueding.feature.extension.login.DaggerExtensionComponent;
import com.fenxiangle.yueding.feature.extension.login.ExtensionPresenterModule;
import com.suozhang.framework.framework.BaseActivity;
import com.suozhang.framework.utils.T;

import org.json.JSONException;
import org.json.JSONObject;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;

public class AlibbActivity extends BaseActivity implements ExtensionContract.View{
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.btn_alibb_pay)
    TextView btnAlibbPay;
    @BindView(R.id.alibb_money)
    TextView alibbMoney;
    @BindView(R.id.payeeAccount)
    EditText payeeAccount;
    @BindView(R.id.realName)
    EditText realName;
    private int commissionType;


    @Inject
    ExtensionContract.Presenter presenter;
    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_alibb;
    }

    @Override
    protected void initInjector() {
        DaggerExtensionComponent.builder().extensionPresenterModule(new ExtensionPresenterModule(this)).build().inject(this);
    }
    String pwdll="";
    @Override
    protected void initData() {


        String money = getIntent().getStringExtra("money");
        pwdll = getIntent().getStringExtra("pwdll");
        commissionType=getIntent().getIntExtra("commissionType",0);
        alibbMoney.setText(money);
        initToolBar(toolbar, "提现", true, true);
        btnAlibbPay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                JSONObject jsonObject=new JSONObject();
                try {
                    jsonObject.put("transactionMount",money);
                    jsonObject.put("forwardType","0");
                    jsonObject.put("payeeAccount",payeeAccount.getText().toString());
                    jsonObject.put("realName",realName.getText().toString());
                    jsonObject.put("paymentPwd",pwdll);
                    jsonObject.put("commissionType",commissionType);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                presenter.user_forward(jsonObject);
            }
        });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @Override
    public void ShowData(ExtensionBo s) {

    }

    @Override
    public void showLoginSuccess() {
        T.showShort("提现成功");
        Intent intent=new Intent();
        intent.putExtra("alibb","1");
        setResult(30002,intent);
        finish();
    }

    @Override
    public void showAliPayBo(AliPayBo aliPayBo) {

    }

    @Override
    public void showWeiChatData(AliPayBo aliPayBo) {
        Intent intent=new Intent();
        intent.putExtra("alibb","1");
        setResult(30002,intent);
        finish();
    }

    @Override
    public void showError(String error) {
        T.showShort(error);
    }

    @Override
    public void showPwd(String pwd) {

    }

    @Override
    public void user_payment_set() {

    }
}
